<template>
  <div class="mycollect">
    <!-- 头部 -->
    <van-nav-bar class="top">
      <template #title>
        <div class="title22">黑马程序员</div>
      </template>
      <template #left>
        <div>
          <van-icon name="arrow-left" @click="goback" class="fanhui" />
        </div>
      </template>
    </van-nav-bar>
    <!-- 标签 -->
    <van-tabs v-model="activeName">
      <van-tab title="我的收藏" name="a">
        <div class="items" v-for="(item, index) in collectList" :key="index">
          <div class="one">
            <div class="left">
              <div class="title">{{ item.title }}</div>
              <div class="time">
                <span class="uname">{{ item.aut_name }}</span>
                <span>{{ item.comm_count }} 评论</span>
                <span>{{ item.pubdate | timefilter }}</span>
              </div>
            </div>
            <div class="right" v-if="item.cover.images[0]">
              <img :src="item.cover.images[0]" />
            </div>
          </div>
          <div class="two">
            <van-row gutter="20">
              <van-col span="8">
                <van-icon name="other-pay" class="myicon" />
                <span> {{ item.comm_count }}</span>
              </van-col>
              <van-col span="8">
                <van-icon name="good-job-o" class="myicon" />
                <span> {{ item.like_count }}</span>
              </van-col>
              <van-col span="8">
                <van-icon name="share-o" class="myicon" />
                <span> 分享</span>
              </van-col>
            </van-row>
          </div>
        </div>
        <div class="nomore">没有更多了</div>
      </van-tab>
      <van-tab title="我的历史" name="b">
        <div class="nomore">没有更多了</div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { getCollect } from '../../../../api/my.js'
export default {
  data () {
    return {
      collectList: []
    }
  },
  computed: {
    activeName () {
      return this.$route.query.type
    }
  },
  methods: {
    // 返回
    goback () {
      this.$router.push('/my')
    },
    // 获取收藏列表
    async getCollectData () {
      const res = await getCollect()
      this.collectList = res.data.results
    }
  },
  created () {
    this.getCollectData()
  }
}
</script>

<style lang="less" scoped>
.mycollect {
  background-color: rgb(245, 247, 249);
  width: 100%;
  height: 100vh;
  font-size: 14px;
}
.myicon {
  font-size: 20px;
  margin-top: 3px;
  vertical-align: text-bottom;
  color: orange;
}
.title22 {
  color: #fff;
}
.left {
  width: 68%;
}
.fenxiang {
  display: inline-block;
}
.right {
  width: 30%;
  height: 60px;
  margin-top: 15px;
  img {
    width: 100%;
    height: 100%;
  }
}
.nomore {
  text-align: center;
  margin-top: 20px;
  color: gray;
}
.uname {
  color: rgb(121, 171, 190);
}
.top {
  background-color: rgb(50, 150, 250);
}
.fanhui {
  color: #fff;
}
.items {
  margin-top: 1px;
  margin-bottom: 10px;
  width: 100%;
  height: 140px;
  background-color: #fff;
  .one {
    height: 90px;
    padding: 0 15px;
    display: flex;
    .title {
      font-size: 18px;
      font-weight: 700;
      padding: 15px 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .time {
      font-size: 14px;
      color: gray;
      span {
        margin-right: 15px;
      }
    }
  }
  .two {
    border-top: 1px solid #eee;
    font-size: 16px;
    text-align: center;
    line-height: 50px;
    color: orange;
  }
}
</style>
